<template>
    <div class="index">
        <div id="login_base">
            <p class="title">Manage Service</p>
            <input type="text" placeholder="Account" v-model="loginFrom.Account">
            <input type="password" placeholder="Password" v-model="loginFrom.Password">
            <button type="submit" class="login_btn" @click="login">login</button>
        </div>
        <div></div>
    </div>
</template>

<script setup>
import { post } from "@/service/baseService.js"
import { Notification } from '@arco-design/web-vue';
import { reactive} from 'vue';
import { useRouter } from "vue-router"
const route = useRouter()
const loginFrom = reactive({
    account:"",
    password:""
})
function login(){
    post("login",loginFrom).then((res)=>{
        if (res.data.code == 200) {
            Notification.success({
                title: '提示',
                content: "登录成功!",
            })
            localStorage.removeItem("token")
            localStorage.setItem("token",res.data.data)
            route.push("/manage")
        } else {
            Notification.error({
                title: '登录失败',
                content: res.data.message,
            })
        }
    }).catch((res)=>{
        console.log(res);
        Notification.error({
            title: '错误提示',
            content: "网络或服务器异常！",
        })
    })
}
</script>
<style scoped>
@import url(@/assets/static/css/login.css);
</style>